<template>
  <view>
    <kevy-empty type="order" :text="description" :show="true"/>
  </view>
</template>

<script>
import utils from "@/utils/utils";
import {relatedOrder} from "@/utils/api/order";

export default {
  data() {
    return {
      description: '订单查询中...'
    };
  },
  methods: {
    guard(opt) {
      this.description = '订单查询中...'
      const q = decodeURIComponent(opt.q)
      let params = utils.getUrlParams(q)
      // this.getyuyinbobao()
      //test(params.order)
      relatedOrder(params.order).then(res => {
        console.log(res)
        if (res.data.data) {
          const order = res.data.data
          console.log('order', order)
          uni.reLaunch({url: `/pagesB/orderdetails/orderdetails?orderNum=${order.orderNum}`})
        } else {
          this.description = '当前订单不存在，3秒后返回首页'
          setTimeout(() => {
            uni.reLaunch({url: '/pages/home/home'})
          }, 3000)
        }
      })
    },
  },
  onLoad(opt) {
    console.log('App Launch', opt)
    // 守卫，需要先通过登录页面
    setTimeout(() => {
      this.guard(opt)
    }, 1000)
  },
}
</script>

<style lang="scss">

</style>
